#include <stdio.h>
#include <stdlib.h>
 
#define bool char
#define MaxSize 1000
 
typedef int ElemType;
 
typedef struct Sk
{
    ElemType data[MaxSize];
    int top;
} Sk;

bool ck(Sk* S)
{
    S->top = -1;
    return 1;
}
 
bool Ey(Sk S)
{
    if(S.top == -1)
        return 1;
    else
        return 0;
}
 
bool Push(Sk* S, ElemType e)
{
    if(S->top == MaxSize-1)
        return 0;
    S->data[++S->top] = e;
    return 1;
}
 
bool Pp(Sk* S, ElemType* e)
{
    if(S->top == -1)
        return 0;
    *e = S->data[S->top--];
    return 1;
}
 
bool Pt(Sk S)
{
    for(int i = 0; i < S.top+1; i++)
    {
        printf("%d ",S.data[i]);
    }
    return 1;
}
 
int main()
{
    Sk S1, S2;
    ck(&S1);
    ck(&S2);
    int er;
 
    char str[1000];
    gets(str);
 
    char c = str[0];
    int i = 0;
    for(i = 0; str[i] != '\0'; i++)
    {
        c = str[i];
        int x, t;
        if(str[i] <= '9' && str[i] >= '0')
        {
            t = 0;
            while(str[i] <= '9' && str[i] >= '0')
            {
                x = str[i]-48;
                t = t*10 + x;
                i++;
            }
 
            Push(&S1, t);
            i--;
        }
        else if(c == ' ')
            continue;
        else if(c == '+' || c == '-' || c == '*')
        {
 
            int m,p;
            Pp(&S1, &m);
            Pp(&S1, &p);
 
            if(c == '+')
            {
                er = p+m;
            }
            else if(c == '-')
            {
                er = p-m;
            }
            else if(c == '*')
            {
                er = p*m;
            }
            Push(&S1, er);
        }
    }
    printf("%d", er);
    return 0;
}